// Config.h
#ifndef CONFIG_H
#define CONFIG_H

#include <string>
#include <json.hpp>

using json = nlohmann::json;

struct RedisConfig {
    std::string host = "172.10.0.8";
    int port = 6379;
    int db = 0;
    std::string password = "";
    int pool_size = 10;
};

struct RocketMQConfig {
    std::string name_server;
    std::string consumer_group;
    std::string topic;
    std::string producer_group;
};

struct ServerConfig {
    int http_port = 8080;
    std::string realm = "admin@password";
    std::string password= "password";// "实际的密码" ;
    int keepalive_check_interval = 60;
    int thread_pool_size = 50;
};

class Config {
public:
    static Config& getInstance() {
        static Config instance;
        return instance;
    }

    bool load(const std::string& config_path);
    
    const RedisConfig& getRedisConfig() const { return redis_; }
    const RocketMQConfig& getRocketMQConfig() const { return rocketmq_; }
    const ServerConfig& getServerConfig() const { return server_; }
    const std::string& getServerRegID() const { return server_reg_id_; }

private:
    Config() = default;
    
    RedisConfig redis_;
    RocketMQConfig rocketmq_;
    ServerConfig server_;
    std::string server_reg_id_ = "10000000005030000520";
};

#endif